package com.example.swd1.gudong.main.sportrang;

import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.ListView;

import com.example.swd1.gudong.R;
import com.example.swd1.gudong.view.ReFreshView;

import java.util.ArrayList;
import java.util.List;


//==================================================================================================================
//   Author :  Shile Wu
//   Date  :  16-8-19
//   Role :    xx
//   Reference documents : xx
//==================================================================================================================
public class SportRangFragmentSquare extends Fragment implements ReFreshView.OnRefreshListener {
    private ReFreshView reFreshList;
    private SquareListViewAdapter adapter;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_sport_rang_square, container, false);

        reFreshList = (ReFreshView) view.findViewById(R.id.sport_rang_square_list);
        adapter = new SquareListViewAdapter(getContext());
        reFreshList.setAdapter(adapter);
        reFreshList.setOnRefreshListener(this);
        return view;
    }

    /*-begin-20160913-shile.wu-add-for-task2781345-*/
    private Handler mHandler = new mHandler();

    @Override
    public void onRefresh() {
        new Thread(new Runnable() {

            @Override
            public void run() {
                try {
                    Thread.sleep(2000);
                    Message message = new Message();
                    message.what = 1;
                    mHandler.sendMessage(message);
                } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }).start();
    }

    public class mHandler extends Handler {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            if (msg.what == 1) {
                reFreshList.setOnRefreshComplete();
            }
        }
    }
    /*-end-20160913-shile.wu-add-for-task2781345-*/
}
